/**
 * 
 */
package org.compiere.model;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;

import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;

/**
 * @author Aslanbek
 *
 */
public class MBPMProjectAgreement extends X_BPM_Project_Agreement {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5616677569781441298L;

	/**
	 * @param ctx
	 * @param BPM_Project_Agreement_ID
	 * @param trxName
	 */
	public MBPMProjectAgreement(Properties ctx, int BPM_Project_Agreement_ID,
			String trxName) {
		super(ctx, BPM_Project_Agreement_ID, trxName);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param ctx
	 * @param rs
	 * @param trxName
	 */
	public MBPMProjectAgreement(Properties ctx, ResultSet rs, String trxName) {
		super(ctx, rs, trxName);
		// TODO Auto-generated constructor stub
	}

	public static MBPMProjectAgreement[] getBPMProjectAgreements(int BPM_Project_ID){
		
	    PreparedStatement pstmt = null;
		ResultSet rs = null;
		MBPMProjectAgreement result = null;
		
		ArrayList<MBPMProjectAgreement> list = new ArrayList<MBPMProjectAgreement>();
		
		String sql_ = "SELECT * FROM "+X_BPM_Project_Agreement.Table_Name+" \n " +
				" WHERE "+X_BPM_Project_Agreement.COLUMNNAME_BPM_Project_ID+"="+BPM_Project_ID;
		try
		{
			pstmt = DB.prepareStatement(sql_,null);
			rs = pstmt.executeQuery();	
			while(rs.next()){
				result = new MBPMProjectAgreement(Env.getCtx(), rs, null);
				list.add(result);
			}				
		}
		catch (SQLException e)
		{
			CLogger.get().log(Level.INFO, "BPM_Project_Agreement", e);
		}
		finally
		{
			DB.close(rs, pstmt);
			rs = null; pstmt = null;
		}	
		
		return list.toArray(new MBPMProjectAgreement[list.size()]);
	}
}
